home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / int24.arc / INT24.ASM next >
Assembly Source File  |  1988-01-06  |  2KB  |  98 lines

  1.       name    INT24_HANDLER
  2.  
  3. CGroup    group    Code
  4.     assume    cs: CGroup
  5.  
  6. Code    segment 'CODE'
  7.     even
  8.     
  9.     public    InstallINT24
  10.  
  11. Int24_Handler_Next    dd    ?
  12. Message            db    'Plug the cable back in. Trying again.',0
  13.  
  14. Int24Handler    proc    near
  15.     push    bx
  16.     mov    bx, di
  17.     cmp    bl, 0Ch        ;General Failure
  18.     jne    GoNextInt24
  19.  
  20.     ;This is the part that could be just about anything.
  21.     ;All I do is tell the user to plug the cable back in.
  22.     push    cs
  23.     pop    ds
  24.     call    Cursor_Address
  25.     mov    si, offset CGroup: Message
  26.     call    Write_String
  27.  
  28.     pop    bx
  29.     assume ds: nothing
  30.     mov    al, 1        ;retry the operation
  31.     iret
  32. GoNextInt24:
  33.     pop    bx
  34.     jmp    [Int24_Handler_Next]
  35. Int24Handler    endp
  36.  
  37.  
  38. ;Assumptions:      DH, DL -- cursor postion
  39. ;        DS:SI  -- string address (NULL terminated)
  40. Write_String    proc    near
  41.     mov    cx, 1        ;output 1 char at a time
  42. Write_String1:
  43.     lodsb
  44.     or    al, al        ;is it a zero ?
  45.     je    Write_String_Exit    
  46.     mov    ah, 10
  47.     int    10h
  48.     mov    ah, 2
  49.     inc    dl
  50.     int    10h
  51.     jmp    Write_String1
  52. Write_String_Exit:
  53.     ret
  54. Write_String    endp
  55.  
  56. ;On Return DX will contain the address of the cursor.
  57. ;    DH is row and DL is column.
  58. Cursor_Address    proc    near
  59.     mov    ax, 40h        ;point es to BIOS segment
  60.     mov    es, ax
  61.     mov    di, 63h        ;point DI to address word
  62.     mov    dx, es:[di]    ;get CRTC address, this will be 3B4h
  63.     mov    al, 14        ;OUT register number
  64.     out    dx, al        ;increment to 3B5h
  65.     inc    dx        ;point dx to Data Register
  66.     in    al, dx        ;read high byte of cursor address
  67.     mov    ah, al        
  68.     dec    dx               ;point dx to Address Register, will 3B4h
  69.     mov    al, 15        ;OUT next register
  70.     out    dx, al        
  71.     inc    dx        ;point    DX to Data Register
  72.     in    al, dx        ;read low byte of address
  73.     and    ax, 07FFh    ;strip PAGE bits from address
  74.     mov    bl, 80        ;then divide by 80
  75.     div    bl
  76.     xchg    ah, al        ;reverse byte for proper form
  77.     mov    dx, ax        ;cursor position
  78.     ret
  79. Cursor_Address    endp
  80.  
  81. InstallINT24    proc    near
  82.     push    cs
  83.     pop    ds
  84.     mov    ax, 3524h        ;get vector
  85.     int    21h
  86.     mov    word ptr Int24_Handler_Next+2, es
  87.     mov    word ptr Int24_Handler_Next, bx
  88.     lea    dx, Int24Handler     ;load address of my handler
  89.     mov    ax, 2524h        ;set vector
  90.     int    21h
  91.     assume     ds: nothing
  92.     ret
  93. InstallINT24    endp
  94.  
  95. Code    ends
  96.     end
  97.  
  98.